import fetch from '../../utils/fetch';
let base = '/api/menu';

export function fetchTree(query) {
    return fetch({
      url: `${base}/tree`,
      method: 'get',
      params: query
    });
  }

export const fethchAll = params => {
    return fetch.get(
        `${base}/all`, 
    );
}

export const get = params => {
    return fetch.get(
        `${base}/` + params
    );
};

export const update = params => { 
    return fetch.put(
        `${base}/update`, 
        params.entity
    ).then(res => res.data);
};

export const add = params => {
    return fetch.post(
        `${base}`,
        params
    ).then(res => res.data);
};

export const put = params => {
    return fetch.put(
        `${base}/update`,
        params
    )
};

export const remove = params => {
    return fetch.delete(
        `${base}/` + params,
    ).then(res => res.data);
};